SQL Editor - Build Query - Show Unions

The UNION statement allows you to combine multiple queries together to create a single result set. All queries in the union SELECT statements must have an equal number of expressions. In addition, these expressions (column names, literals, dates, results from functions, etc.) must be of compatible data types.

Argos does not check to make sure you have added the correct number of columns or that the data types of the columns added are the same. So be sure to check this. Note that when adding columns in the UNION window, there is no spot for the "AS" or "Description" fields. These will default to the values set in the Main query.

To create a union query:

  1. Click on the Show Unions button.
  2. Select the type of Union (from the Union Toolbar) you would like to add to your main query.
  3. Create your query.

You can add multiple unions to your query list. To edit the query for a particular union or the main query, select it from the query list.

This is the Edit DataBlock dialog with Show Unions selected.   The Report Query tab is selected, showing icons that are used to specify a standard union, union all, and intersect union.

Union Toolbar

Button Description
Union button A standard union combines the results of the two queries into one result set excluding any duplicate records.
Union All button A UNION ALL union combines the results of the two queries into one result set and does not remove any duplicate records.
Intersection button An INTERSECT union returns only those records that exist in both.
Minus button A MINUS union returns all records from the first query except for those records which also exist in the second query.
Delete Union button Delete the union query from your list of queries.
Copy button Copy the union query to the clipboard.
Paste button Paste the query from the clipboard into the current union, overwriting it.
Edit Union button Edit the union properties. Set the name and the type of union.
View SQL button View the SQL generated by all of the union queries together.

 

Sample SQL

Clicking the View SQL button shows you the SQL statement that contains the full query, including any unions. In this example, the main query is unioned with two additional queries that select the departments from three different tables:

select departments.dname from departments where departments.dname = "Accounting" union select departments.dname from departments where departments.dname = "Finance" union select departments.dname from departments where departments.dname = "Sales"

 


Need More Help?